package presentation.util;

import java.util.LinkedList;
import java.util.List;

import javax.faces.application.FacesMessage;
import org.apache.myfaces.shared_impl.util.MessageUtils;

public class BeanUtil {
	public static final String BUNDLE_BASE_NAME = "resources/message";
	
	public static List<Character> getStartLetters(List<String> _alphabeticallyOrderedNames) {
		List<Character> startChars = new LinkedList<Character>();
		char refChar = _alphabeticallyOrderedNames.get(0).charAt(0);
		startChars.add(new Character(refChar));
		char currentChar;
		
		for (int i = 0; i < _alphabeticallyOrderedNames.size(); i++) {
			currentChar = _alphabeticallyOrderedNames.get(i).charAt(0);
			if (currentChar != refChar) {
				startChars.add(new Character(currentChar));
				refChar = currentChar;
			}				
		}
		return startChars;
	}
	
	public static void createGlobalErrorFacesMessage(String msgBundleKey) {
		MessageUtils.addMessage(BUNDLE_BASE_NAME, FacesMessage.SEVERITY_ERROR, msgBundleKey, null);
	}
}